import Jsr from "../../jsr/Jsr.js"
import Blocks from "../../jsr/Blocks.js"
import StrTo from "../../jsr/StrTo.js"

import RunEntity from "./RunEntity.js"


export default function   RunJsr(name,obj,value,type){

    let comms=[]
   let root= qguan("root")
    let data=root.findData(name+".jsr")

    data.then((data1)=>{
            let jsr =new Jsr();
            jsr.loadData(data1);
            let num=  jsr.findFile(obj);
            let blocks=new Blocks();

            let buff=  new Uint8Array(num);
            blocks.decode([buff]);
            let block= blocks.findBlock(1)

            for (let i=0;i<block.length;i++){
                let comm=[];
                let row=block.findRow(i+1);
                for(let l=0;l<4;l++){
                    comm.push(StrTo.numToUtf8(row.find(l+1)))
                }
                 comms.push(comm)
            }


            let runEnt=  new    RunEntity(comms)
            let run= qguan('run')
            let runContext= run();
            runContext.add(runEnt);
    })

}